
import React, { useState } from 'react';
import Son from './Son';

export default function MemoDemo() {

    console.log("MemoDemo被调用了");
    const [count,setCount] = useState(8);
    const [price,setPrice] = useState(2.5);

    function changeCount(){
        setCount(count+1);
    }

    function changePrice(){
        setPrice(price+1);
    }

    function fn(){
        console.log("fn");
    }

  return (
    <div>
        <h1>memo高阶组件</h1>
        <p>count:{count}</p>
        <input type="button" value="修改count" onClick={changeCount} />
        <input type="button" value="修改价格" onClick={changePrice} />
        <hr/>
        <Son price={price} fn={fn} ></Son>
    </div>
  )
}
